import { BaseWindow } from "../../../../component/window/BaseWindow";
import { ILayer } from "../../../../mvc/interfaces/ILayer";
import { DataProvider } from "../../../../../fl/data/DataProvider";
import { Language } from "../../../../../extend/language/Language";
import { ObjCreate } from "../../common/ObjCreate";
import { TilePanel } from "../../equipment/TilePanel";
import { PetSkillViewRenderer } from "./PetSkillViewRenderer";
import { SPetInfo } from "../../../../../Message/Game/SPetInfo";
import { PetManualConfig } from "../../../resource/PetManualConfig";
import { TSkill } from "../../../../../Message/Db/Tables/TSkill";
import { PetUtil } from "../info/PetUtil";
type int = number;
//class PetSkillViewWindow
    
    export  class PetSkillViewWindow extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            this._skillsDp = new DataProvider();
            this.setSize(560, 235);
            this.titleHeight = 28;
            this.title = Language.getString(54566);
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            ObjCreate.createFlowerBg(18, 40, 525, 185, this);
            this._skillList = new TilePanel();
            this._skillList.horizontalGap = 5;
            this._skillList.verticalGap = 0;
            this._skillList.columnWidth = 120;
            this._skillList.rowHeight = 140;
            this._skillList.setSize(510, 150);
            this._skillList.move(30, 50);
            this._skillList.setStyle("cellRenderer", PetSkillViewRenderer);
            this.addChild(this._skillList);
            this._tipTxt = ObjCreate.createTextField("", 40, 203, 220, 20, this);
            this._tipTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._tipTxt.htmlText = Language.getString(54567);
            return;
        }

        public updateSkillInfo(arg1: int, arg2: SPetInfo): void
        {
            var loc1=PetManualConfig.instance.getSkillArrayById(arg1);
            this._petInfo = arg2;
            this.updateSkillList(loc1);
            return;
        }

        /* internal  */updateSkillList(arg1: Array<any>): void
        {
            var loc1=false;
            var loc2=null;
            var loc4=0;
            this._skillsDp.removeAll();
            var loc3=this.getStudyIndex(arg1);
            if (!(arg1 == null) && arg1.length > 0) 
            {
                loc4 = 0;
                while (loc4 < 4) 
                {
                    loc2 = arg1[loc4] as TSkill;
                    if (loc2) 
                    {
                        loc1 = PetUtil.isStudySkill(loc2.skillId, this._petInfo);
                    }
                    if (loc4 <= loc3) 
                    {
                        loc1 = true;
                    }
                    this._skillsDp.addItem({"skill": loc2, "isStudy": loc1});
                    ++loc4;
                }
            }
            this._skillList.dataProvider = this._skillsDp;
            return;
        }

        /* internal  */getStudyIndex(arg1: Array<any>): int
        {
            var loc2=null;
            var loc3=false;
            var loc4=0;
            var loc1=-1;
            if (!(arg1 == null) && arg1.length > 0) 
            {
                loc4 = 0;
                while (loc4 < 4) 
                {
                    loc2 = arg1[loc4] as TSkill;
                    if (loc2) 
                    {
                        if (loc3 = PetUtil.isStudySkill(loc2.skillId, this._petInfo)) 
                        {
                            loc1 = loc4;
                        }
                    }
                    ++loc4;
                }
            }
            return loc1;
        }

        /* internal */ /* var */_skillList: TilePanel;

        /* internal */ /* var */_tipTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_skillsDp: DataProvider;

        /* internal */ /* var */_petInfo: SPetInfo;
    }
